package cn.itcast.web.servlet;

import cn.itcast.domain.Change;
import cn.itcast.service.ChangeService;
import cn.itcast.service.impl.ChangeServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/findChangeByIdServlet")
public class FindChangeByIdServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //设置编码
        request.setCharacterEncoding("utf-8");
        //1获取id,uid,uname
        String id = request.getParameter("id");
        String uid = request.getParameter("uid");
        String uname = request.getParameter("uname");
        /* System.out.println(uid+"a");*/
        //2调用service查询
        ChangeService service=new ChangeServiceImpl();
        Change change=service.findChangeById(id);
        //3设置参数
        request.setAttribute("change",change);
        request.setAttribute("uid",uid);
        request.setAttribute("uname",uname);
        request.getRequestDispatcher("/ChangeInfobupdate.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
